package com.example.demo.offer;

import java.util.HashMap;
import java.util.Map;

public class Offer06 {
    public static void main(String[] args) {

    }

    public static int[] twoSum(int[] numbers, int target) {
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < numbers.length; i++) {
            if (map.containsKey(numbers[i])) {
                return new int[]{map.get(numbers[i]), i};
            } else {
                map.put(target - numbers[i], i);
            }
        }
        return new int[]{};
    }
}
